@extends('admin.app')

@section('breadcrumb')
<div class="bg-light lter b-b wrapper-md">
  <ol class="breadcrumb bg-light lter m-n no-padder">
    <li><a href="{{ admin_action('HomeController@index') }}">主页</a></li>
    <li>网站管理</li>
    <li class="active">导航管理</li>
  </ol>
</div>
@endsection

@section('content')
  <div class="panel panel-default">
    <div class="panel-heading font-bold">
      导航管理列表
    </div>
    <div class="row wrapper">
      <div class="col-sm-8">
        <form class="form-horizontal" method="get" action="{{ admin_action('Web\NavigationsController@index') }}">
          <div class="row">
            <div class="col-sm-5">
              <div class="form-group">
                <label class="control-label col-sm-4">导航名称:</label>
                <div class="col-sm-8">
                  <input class="form-control" type="text" placeholder="请输入导航名称" name="name"
                         value="{{ $query['name'] }}"/>
                </div>
              </div>
            </div>

            <div class="col-sm-5">
              <div class="form-group">
                <label class="control-label col-sm-4">父级导航:</label>
                <div class="col-sm-8">
                  <select name="parent_id" class="form-control select2">
                    <option value="">----请选择父级导航----</option>
                    @foreach( $parents as $id=>$name)
                      @if($id == $query['parent_id'])
                        <option value="{{ $id }}" selected="selected">{{ $name }}</option>
                      @else
                        <option value="{{ $id }}">{{ $name}}</option>
                      @endif
                    @endforeach
                  </select>
                </div>
              </div>
            </div>
            <div class="col-sm-1 text-left">
            <span class="input-group-btn">
              <button class="btn btn-sm btn-default" type="submit">查询</button>
            </span>
              </div>
          </div>
        </form>
      </div>
      <div class="col-sm-4 text-right text-center-xs">
          @accredit('web.navigations.create')
              <a class="btn m-b-xs btn-sm btn-default btn-addon" href="{{ admin_action('Web\NavigationsController@create') }}">
                  <i class="fa fa-plus"></i>新增导航记录
              </a>
          @endaccredit
      </div>
    </div>
    <div class="table-responsive">
      <table class="table table-striped b-t b-light">
        <thead>
          <tr>
              <th>编号</th>
              <th>导航名称</th>
              <th>排序</th>
              <th>父级名称</th>
              <th>操作</th>
          </tr>
        </thead>
        <tbody>
          @forelse ($navigations as $navigation)
          <tr>
            <td>{{ $navigation->id }}</td>
            <td>{{ $navigation->name }}</td>
            <td>{{ $navigation->sort }}</td>
            <td>{{ $navigation->parent_name??'无'}}</td>
            <td>
              @accredit('web.navigations.show')
              <a class="btn btn-xs btn-primary" href="{{ admin_action('Web\NavigationsController@show', [$navigation]) }}" data-toggle="tooltip" title="查看该导航详情">
                <i class="fa fa-info"></i>
              </a>
              @endaccredit
              @accredit('web.navigations.edit')
              <a class="btn btn-xs btn-primary" href="{{ admin_action('Web\NavigationsController@edit', [$navigation]) }}" data-toggle="tooltip" title="编辑导航信息">
                <i class="fa fa-pencil"></i>
              </a>
              @endaccredit
              @accredit('web.navigations.destroy')
              <form class="inline" action="{{ admin_action('Web\NavigationsController@destroy', [$navigation]) }}" method="post">
                {{ csrf_field() }}
                {{ method_field('DELETE') }}
                <button type="button" data-swal-role="delete-confirm" data-swal-title="温馨提示" data-swal-text="您将删除导航 <{{ $navigation->name }}>   " class="btn btn-xs btn-danger" data-toggle="tooltip" title="删除导航信息">
                  <i class="fa fa-trash-o"></i>
                </button>
              </form>
              @endaccredit
            </td>
          </tr>
          @empty
          <tr>
            <td colspan="3" class="text-center">没有找到导航记录</td>
          </tr>
          @endforelse
        </tbody>
      </table>
    </div>
    <div class="panel-footer">
      <div class="row">
        <div class="col-sm-12 text-right text-center-xs">
          {!! $links !!}
        </div>
      </div>
    </div>
  </div>
@endsection